<?php

class Admin extends CI_Controller {

    //constructeur de la classe
    public function __construct() {
        parent::__construct();
        if ($this->session->userdata('username') == "") {
            redirect('connexion');
        }
    }

    function index() {
        $this->template->load('template', 'Page/administration');
    }
    
    function ajoutervalider()
    {
        $titre = $this->input->post("titre");
        $texte = $this->input->post("texte");
        $page = $this->input->post("page");
        $this->article_model->createArticle($titre, $texte, $page);
        redirect("Page/accueil", "refresh");
      $tite = $this->input->post("titre");
      echo $titre;
    }
    
    function modifier($id)
    {
          
        // set validation properties
        $this->_set_fields();
         
        // prefill form values
        $person = $this->article_model->get_by_id($id)->row();
        $this->validation->id = $id;
        $this->validation->titre = $titre->titre;
         $this->validation->texte = $texte->texte;
        $_POST['gender'] = strtoupper($person->gender);

         
        // set common properties
        $data['title'] = 'Update person';
        $data['message'] = '';
        $data['action'] = site_url('person/updatePerson');
        $data['link_back'] = anchor('person/index/','Back to list of persons',array('class'=>'back'));
     
        // load view
        $this->load->view('personEdit', $data);
  
    }
  
    
    

}
?>